<template>
    <el-container>
        <el-main>
            <avue-crud ref="multipleTable" :data="tableData" :option="tableColumns" :page="page" @refresh-change="refresh"
                @search-change="searchChange" @search-reset="searchReset" @filter-change="filterChange" @size-change="sizeChange"
                @current-change="currentChange">

                <template slot="menuLeft">
                    <el-button v-for="(item,index) in btnList" :disabled="item.disabled" :key="index" :type="item.type"
                        :class="{'hide': item.hide}" @click.native="btnclick(item.funName)" size="small">{{ item.label }}</el-button>
                </template>
                <template slot="menu" slot-scope="{row}">
                    <el-button v-if="row.wf01004 === 0" size="small" type="text" class="successbtn-color" @click.native="enabled(row)">
                        启用
                    </el-button>
                    <el-button v-if="row.wf01004 === 1" size="small" type="text" class="dangerbtn-color" @click.native="disabled(row)">
                        禁用
                    </el-button>
                    <el-button size="small" type="text" class="primarybtn-color" @click.native="edit(row)">
                        编辑
                    </el-button>
                    <!-- <el-button v-if="row.wf01004 === 0" size="small" type="text" class="primarybtn-color" @click.native="globalset(row)"> -->
                    <el-button size="small" type="text" class="primarybtn-color" @click.native="globalset(row)">
                        全局配置
                    </el-button>
                    <el-button v-if="row.wf01004 === 0" size="small" type="text" class="primarybtn-color" @click.native="design(row)">
                        流程设计
                    </el-button>
                    <!-- <el-button v-if="row.wf01004 === 0" size="small" type="text" class="primarybtn-color" @click.native="jobset(row)"> -->
                    <el-button size="small" type="text" class="primarybtn-color" @click.native="jobset(row)">
                        业务表设计
                    </el-button>
                    <!-- <el-button v-if="row.wf01004 === 0" size="small" type="text" class="primarybtn-color" @click.native="formdesign(row)"> -->
                    <el-button size="small" type="text" class="primarybtn-color" @click.native="formdesign(row)">
                        表单设计
                    </el-button>
                    <!-- <el-button v-if="row.wf01004 === 0" size="small" type="text" class="primarybtn-color" @click.native="nodeset(row)"> -->
                    <el-button size="small" type="text" class="primarybtn-color" @click.native="nodeset(row)">
                        节点配置
                    </el-button>
                    <!-- <el-button v-if="row.wf01004 === 0" size="small" type="text" class="primarybtn-color" @click.native="birt(row)"> -->
                    <el-button size="small" type="text" class="primarybtn-color" @click.native="birt(row)">
                        报表设计
                    </el-button>
                    <!-- <el-button size="small" type="text" class="primarybtn-color" @click.native="upgradesql(row)">
                        升级脚本
                    </el-button> -->
                    <el-button size="small" type="text" class="primarybtn-color" @click.native="processsql(row)">
                        过程脚本
                    </el-button>
                    <el-button size="small" type="text" class="primarybtn-color" @click.native="jobcolumnviewed(row)">
                        业务字段EXCEL导出
                    </el-button>
                </template>
                <template slot="wf01004" slot-scope="scope">
                    <div v-if="scope.row.wf01004 === 1" style="color:#13ce66">启用</div>
                    <div v-if="scope.row.wf01004 === 0" style="color:#ff4949">禁用</div>
                </template>
            </avue-crud>
            <!-- 流程表单-->
            <el-dialog :title="dialogFormTitle" :destroy-on-close="false" :close-on-click-modal="false" :visible.sync="dialogFormVisible"
                :before-close="handleCloseBindDialogForm" width="500px">
                <div style="height:60px;overflow:auto">
                    <df-element-form v-if="formHackReset" :formConfig="formConfig[0]" :value="formValue" ref="customForm">
                    </df-element-form>
                </div>
                <el-row slot="footer" class="dialog-footer" style="text-align: center;">
                    <el-button size="small" type="primary" @click="save">保存</el-button>
                    <el-button size="small" @click="dialogFormVisible = false;">取消</el-button>
                </el-row>
            </el-dialog>

            <!-- 流程设计-->
            <el-dialog :title="dialogFormTitleDesign" :destroy-on-close="true" :close-on-click-modal="false"
                :visible.sync="dialogFormVisibleDesign" :before-close="handleCloseBindDialogDesign" fullscreen>
                <iframe :src="flowSrc" frameborder="0" width="100%" height="1000px"></iframe>
            </el-dialog>

            <!-- 报表设计-->
            <el-dialog :title="dialogBirtTitle" :destroy-on-close="false" :close-on-click-modal="false" :visible.sync="dialogBirtVisible"
                :before-close="handleCloseBirtDialog" fullscreen>
                <el-container>
                    <el-aside width="400px">
                        <el-tree ref="nodeTree" class="aside-tree" :data="nodeTreeData" node-key="id" accordion
                            default-expand-all highlight-current check-on-click-node :expand-on-click-node="false"
                            @node-click="handleNodeClick">
                        </el-tree>
                    </el-aside>
                    <el-main>
                        <avue-crud :data="birttableData" :option="birttableColumns" @refresh-change="birtrefresh">
                            <template slot="menuLeft">
                                <el-button v-for="(item,index) in birtbtnList" :key="index" :type="item.type" :class="item.hide?'hide':''"
                                    @click.native="btnclick(item.funName)" size="small">{{ item.label }}</el-button>
                            </template>
                            <template slot="menu" slot-scope="{row}">
                                <el-button v-if="row.wf04010 === 0" size="small" type="text" class="successbtn-color"
                                    @click.native="detailenabled(row)">
                                    启用
                                </el-button>
                                <el-button size="small" type="text" class="primarybtn-color" @click.native="detailedit(row)">
                                    编辑
                                </el-button>
                                <el-button v-if="$store.state.user.permission.dict_detail_del" size="small" type="text"
                                    class="dangerbtn-color" @click.native="detaildel(row)">
                                    删除
                                </el-button>
                                <el-button v-if="row.wf04010 === 1" size="small" type="text" class="dangerbtn-color"
                                    @click.native="detaildisabled(row)">
                                    禁用
                                </el-button>
                                <el-button size="small" type="text" class="primarybtn-color" @click.native="detailsimulation(row)">
                                    模拟
                                </el-button>
                            </template>
                            <template slot="wf04010" slot-scope="scope">
                                <div v-if="scope.row.wf04010 === 1" style="color:#13ce66">启用</div>
                                <div v-if="scope.row.wf04010 === 0" style="color:#ff4949">禁用</div>
                            </template>
                            <template slot="wf04007" slot-scope="scope">
                                <div v-if="scope.row.wf04007 === 1">列表</div>
                                <div v-if="scope.row.wf04007 === 0">详情</div>
                            </template>
                            <template slot="wf04008" slot-scope="scope">
                                <div v-if="scope.row.wf04008 === 1">转</div>
                                <div v-if="scope.row.wf04008 === 0">不转</div>
                            </template>
                            <template slot="wf04009" slot-scope="scope">
                                <div v-if="scope.row.wf04009 === 1">是</div>
                                <div v-if="scope.row.wf04009 === 0">否</div>
                            </template>
                        </avue-crud>
                        <el-dialog :title="detailinnerDialogFormTitle" :destroy-on-close="false" :close-on-click-modal="false"
                            :visible.sync="detailinnerVisible" :before-close="handleCloseBindDetailDialogForm"
                            append-to-body top="15vh" width="635px">
                            <div style="height:420px;overflow: hidden;">
                                <df-element-form v-if="detailFormHackReset" ref="detailForm" :formConfig="detailFormConfig[0]"
                                    :value="detailFormValue">
                                </df-element-form>
                            </div>
                            <avue-form :option="singleOption" v-model="singleObj">
                            </avue-form>
                            <avue-form :option="multiOption" v-model="multiObj">
                            </avue-form>
                            <el-row slot="footer" class="dialog-footer" style="text-align: center;">
                                <el-button size="small" type="primary" @click="detailsave">保存</el-button>
                                <el-button size="small" @click="detailinnerVisible = false;">取消</el-button>
                            </el-row>
                        </el-dialog>
                    </el-main>
                </el-container>
            </el-dialog>

            <!-- 业务表设计-->
            <el-dialog :title="jobTitle" :destroy-on-close="false" :close-on-click-modal="false" :visible.sync="jobVisible"
                :before-close="handleCloseJob" fullscreen>
                <el-container>
                    <el-aside width="350px">
                        <el-button v-if="jobTreeData.length === 0" type="primary" size="small" @click="createJob">创建主表</el-button>
                        <el-tree ref="jobTree" class="aside-tree" :data="jobTreeData" node-key="id" accordion
                            default-expand-all highlight-current check-on-click-node :expand-on-click-node="false"
                            @node-click="handleJobClick">
                            <span class="custom-tree-node" slot-scope="{ node, data }">
                                <span>({{ data.table }}){{ node.label }}</span>
                                <span>
                                    <el-button v-if="data.ismain == '1'" class="primarybtn-color" type="text" size="mini"
                                        @click="() => createJob()">
                                        添加
                                    </el-button>
                                    <el-button class="primarybtn-color" type="text" size="mini" @click="() => editJob(node, data)">
                                        编辑
                                    </el-button>
                                    <el-button v-if="data.system == '0' && data.ismain == '0'" class="dangerbtn-color"
                                        type="text" size="mini" @click="() => removeJob(node, data)">
                                        删除
                                    </el-button>
                                </span>
                            </span>
                        </el-tree>
                    </el-aside>
                    <el-main>
                        <avue-crud ref="jobConfigCrud" :option="jobConfigAvueOption" :data="jobConfigAvueData"
                            @row-update="jobConfigAddUpdate" @row-del="jobConfigDel">
                            <template slot="menuLeft">
                                <el-button v-for="(item,index) in jobConfigbtnList" :key="index" :type="item.type"
                                    :class="item.hide?'hide':''" @click.native="btnclick(item.funName)" size="small">{{ item.label }}</el-button>
                            </template>
                        </avue-crud>
                    </el-main>
                    <el-dialog :title="jobConfigFormTitle" :destroy-on-close="false" :close-on-click-modal="false"
                        :visible.sync="jobConfigVisible" :before-close="handleCloseBindJobConfigForm" append-to-body
                        top="15vh" width="435px">
                        <div style="height:220px;overflow: hidden;">
                            <df-element-form v-if="jobConfigFormHackReset" ref="jobConfigForm" :formConfig="jobConfigForm[0]"
                                :value="jobConfigFormValue">
                            </df-element-form>
                        </div>
                        <el-row slot="footer" class="dialog-footer" style="text-align: center;">
                            <el-button size="small" type="primary" @click="jobConfigSave">保存</el-button>
                            <el-button size="small" @click="jobConfigVisible = false;">取消</el-button>
                        </el-row>
                    </el-dialog>
                </el-container>
            </el-dialog>

            <!-- 表单设计-->
            <el-dialog :title="formDesignTitle" :destroy-on-close="false" :close-on-click-modal="false" :visible.sync="formDesignVisible"
                :before-close="handleCloseFormDesign" fullscreen>
                <avue-crud ref="formDesignTable" :data="formDesigntableData" :option="formDesigntableColumns"
                    @refresh-change="handleFormDesignRefresh" @row-save="handleFormDesignSave" @row-update="handleFormDesignUpdate">
                    <template slot="menu" slot-scope="{row}">
                        <el-button v-if="row.formStatus === 0" size="small" type="text" class="successbtn-color" @click="formDesignEnabled(row)">
                            启用
                        </el-button>
                        <el-button v-if="row.formStatus === 1" size="small" type="text" class="dangerbtn-color" @click="formDesignDisabled(row)">
                            禁用
                        </el-button>
                        <el-button size="small" type="text" class="dangerbtn-color" @click="handleFormDesignRemove(row)">删除</el-button>
                        <el-button size="small" type="text" class="primarybtn-color" @click.native="formDesignConfig(row)">
                            表单设计
                        </el-button>
                    </template>
                    <template slot="formStatus" slot-scope="scope">
                        <div v-if="scope.row.formStatus === 1" style="color:#13ce66">启用</div>
                        <div v-if="scope.row.formStatus === 0" style="color:#ff4949">禁用</div>
                    </template>
                    <template slot="firstShow" slot-scope="scope">
                        <div v-if="scope.row.firstShow === 1" style="color:#13ce66">默认</div>
                        <div v-if="scope.row.firstShow === 0" style="color:#ff4949">其他</div>
                    </template>
                    <template slot="formStatusForm" slot-scope="scope">
                        <div>
                            <el-radio-group v-model="scope.row.formStatus">
                                <el-radio :label="1">启用</el-radio>
                                <el-radio :label="0">禁用</el-radio>
                            </el-radio-group>
                        </div>
                    </template>
                    <template slot="firstShowForm" slot-scope="scope">
                        <div>
                            <el-radio-group v-model="scope.row.firstShow">
                                <el-radio :label="1">默认</el-radio>
                                <el-radio :label="0">其他</el-radio>
                            </el-radio-group>
                        </div>
                    </template>
                </avue-crud>
                <el-dialog :title="formDesignConfigTitle" :destroy-on-close="true" :close-on-click-modal="false"
                    :visible.sync="formDesignConfigVisible" :before-close="handleCloseFormDesignConfig"
                    append-to-body fullscreen>
                    <avue-form-design :options="formDesignConfigOption" @submit="handleSubmitFormDesign"></avue-form-design>
                </el-dialog>
            </el-dialog>

            <!-- 节点配置-->
            <el-dialog :title="nodeTitle" :destroy-on-close="false" :close-on-click-modal="false" :visible.sync="nodeVisible"
                :before-close="handleCloseNode" fullscreen>
                <el-container>
                    <el-aside width="200px">
                        <el-menu default-active="2" class="el-menu-vertical-demo">
                            <el-submenu index="flownode">
                                <template slot="title">
                                    <span>流程节点</span>
                                </template>
                                <el-menu-item-group>
                                    <el-menu-item @click="nodeSetCheck(0, item)" v-for="(item,index) in nodeData" :key="index"
                                        :index="index.toString()">
                                        {{item.wf02003}}
                                    </el-menu-item>
                                </el-menu-item-group>
                            </el-submenu>
                            <!-- <el-submenu index="syselse">
                                <template slot="title">
                                    <span>其他设置</span>
                                </template>
                                <el-menu-item-group>
                                    <el-menu-item key="-99" index="-99">时间节点配置</el-menu-item>
                                </el-menu-item-group>
                            </el-submenu> -->
                        </el-menu>
                    </el-aside>
                    <el-main>
                        <avue-tabs :option="nodeSetOption" @change="nodeSetHandleChange"></avue-tabs>
                        <span v-if="nodeTabCheck.prop==='step1'">
                            <div style="text-align: center">
                                <el-transfer style="text-align: left; display: inline-block" v-model="nodeColumnValue"
                                    filterable :titles="['可选字段', '已选字段']" :data="nodeColumnData">
                                    <el-button style="display: none;" class="transfer-footer" slot="left-footer" size="small">操作</el-button>
                                    <el-button class="transfer-footer" slot="right-footer" size="small" @click="nodeColumnSave(1)">保存</el-button>
                                </el-transfer>
                            </div>
                        </span>
                        <span v-else-if="nodeTabCheck.prop==='step2'">
                            <avue-crud ref="nodeColumnListCrud" :option="nodeColumnListOption" :data="nodeColumnList"
                                @row-update="nodeColumnListUpdate" @sortable-change="nodeColumnListSortableChange">
                                <template slot="menuLeft">
                                    <el-button @click="nodeColumnListOrderSave" type="primary" size="small">排序保存</el-button>
                                </template>
                            </avue-crud>
                        </span>
                        <!-- <span v-else-if="nodeTabCheck.prop==='step3'">内置字段设置</span> -->
                        <span v-else-if="nodeMenuCheck.wf02005 == 1 && nodeTabCheck.prop==='step4'">
                            <el-form :model="examConfigForm" :rules="examConfigRules" ref="examConfigForm" label-width="120px">
                                <el-form-item label="审核结果" prop="examResult">
                                    <el-col class="line" :span="8">
                                        <el-select v-model="examConfigForm.examResult" filterable placeholder="请选择">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="(item, index) in examColumns" :key="index" :label="item.label"
                                                :value="item.value"></el-option>
                                        </el-select>
                                    </el-col>
                                </el-form-item>
                                <el-form-item label="审核时间" prop="examDate">
                                    <el-col class="line" :span="8">
                                        <el-select v-model="examConfigForm.examDate" filterable placeholder="请选择">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="(item, index) in examColumns" :key="index" :label="item.label"
                                                :value="item.value"></el-option>
                                        </el-select>
                                    </el-col>
                                </el-form-item>
                                <el-form-item label="审核意见" prop="examReason">
                                    <el-col class="line" :span="8">
                                        <el-select v-model="examConfigForm.examReason" filterable placeholder="请选择">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="(item, index) in examColumns" :key="index" :label="item.label"
                                                :value="item.value"></el-option>
                                        </el-select>
                                    </el-col>
                                </el-form-item>
                                <el-form-item label="审核人员" prop="examPerson">
                                    <el-col class="line" :span="8">
                                        <el-select v-model="examConfigForm.examPerson" filterable placeholder="请选择">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="(item, index) in examColumns" :key="index" :label="item.label"
                                                :value="item.value"></el-option>
                                        </el-select>
                                    </el-col>
                                </el-form-item>
                                <el-form-item>
                                    <el-button type="primary" @click="examConfigSave">保存</el-button>
                                </el-form-item>
                            </el-form>
                            </el-form>
                        </span>
                    </el-main>
                </el-container>
            </el-dialog>

            <!-- 全局配置 -->
            <el-dialog :title="globalTitle" :destroy-on-close="false" :close-on-click-modal="false" :visible.sync="globalVisible"
                :before-close="handleCloseGlobal" fullscreen>
                <el-container>
                    <el-main>
                        <avue-tabs :option="globalSetOption" @change="globalSetHandleChange"></avue-tabs>
                        <span v-if="globalTabCheck.prop==='ordernumber'">
                            <el-form ref="ordernumberForm" :model="ordernumberForm" label-width="120px">
                                <el-form-item label="编码类型">
                                    <el-select v-model="ordernumberForm.type" placeholder="请选择">
                                        <el-option label="系统随机数字码" value="sysnum"></el-option>
                                        <el-option label="系统随机字符码" value="sysstr"></el-option>
                                        <el-option label="指定规则码" value="syspoint"></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="指定规则码" v-show="ordernumberForm.type === 'syspoint'">
                                    <el-col :span="6">
                                        <el-form-item prop="prefix">
                                            <el-input v-model="ordernumberForm.prefix" placeholder="前缀"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col class="line" :span="4">
                                        <el-select v-model="ordernumberForm.connectp" placeholder="请选择">
                                            <el-option label="空" value="0"></el-option>
                                            <el-option label="减号" value="1"></el-option>
                                            <el-option label="下划线" value="2"></el-option>
                                        </el-select>
                                    </el-col>
                                    <el-col :span="6">
                                        <el-select v-model="ordernumberForm.date" placeholder="请选择规则">
                                            <el-option label="年月日" value="ymd"></el-option>
                                            <el-option label="年-月-日" value="y-m-d"></el-option>
                                            <el-option label="年_月_日" value="y_m-d"></el-option>
                                            <el-option label="年月" value="ym"></el-option>
                                            <el-option label="年-月" value="y-m"></el-option>
                                            <el-option label="年_月" value="y_m"></el-option>
                                        </el-select>
                                    </el-col>
                                    <el-col class="line" :span="4">
                                        <el-select v-model="ordernumberForm.connectd" placeholder="请选择">
                                            <el-option label="空" value="0"></el-option>
                                            <el-option label="减号" value="1"></el-option>
                                            <el-option label="下划线" value="2"></el-option>
                                        </el-select>
                                    </el-col>
                                    <el-col class="line" :span="4">
                                        <el-select v-model="ordernumberForm.randnum" placeholder="请选择自增位">
                                            <el-option label="自增三位" value="3"></el-option>
                                            <el-option label="自增四位" value="4"></el-option>
                                            <el-option label="自增五位" value="5"></el-option>
                                            <el-option label="自增六位" value="6"></el-option>
                                        </el-select>
                                    </el-col>
                                </el-form-item>
                                <el-form-item>
                                    <el-button type="primary" @click="globalTabSave">保存</el-button>
                                </el-form-item>
                            </el-form>
                        </span>
                        <span v-if="globalTabCheck.prop==='systemname'">
                            <el-form ref="systemnameForm" :model="systemnameForm" label-width="120px">
                                <el-form-item label="NUMBER">
                                    <el-col class="line" :span="8">
                                        <el-select v-model="systemnameForm.numberstatus" placeholder="请选择">
                                            <el-option label="启用" value="1"></el-option>
                                            <el-option label="隐藏" value="0"></el-option>
                                        </el-select>
                                    </el-col>
                                    <el-col class="line" :span="8">
                                        <el-input v-model="systemnameForm.numberkey" disabled></el-input>
                                    </el-col>
                                    <el-col class="line" :span="8">
                                        <el-input v-model="systemnameForm.numbershow"></el-input>
                                    </el-col>
                                </el-form-item>

                                <el-form-item label="NAME">
                                    <el-col class="line" :span="8">
                                        <el-select v-model="systemnameForm.namestatus" placeholder="请选择">
                                            <el-option label="启用" value="1"></el-option>
                                            <el-option label="隐藏" value="0"></el-option>
                                        </el-select>
                                    </el-col>
                                    <el-col class="line" :span="8">
                                        <el-input v-model="systemnameForm.namekey" disabled></el-input>
                                    </el-col>
                                    <el-col class="line" :span="8">
                                        <el-input v-model="systemnameForm.nameshow"></el-input>
                                    </el-col>
                                </el-form-item>

                                <el-form-item label="快捷搜索">
                                    <el-col class="line" :span="8">
                                        <el-select v-model="systemnameForm.keywordstatus" placeholder="请选择">
                                            <el-option label="启用" value="1"></el-option>
                                            <el-option label="隐藏" value="0"></el-option>
                                        </el-select>
                                    </el-col>
                                    <el-col class="line" :span="8">
                                        <el-input v-model="systemnameForm.keywordplaceholder"></el-input>
                                    </el-col>
                                </el-form-item>
                                <el-form-item label="列表按钮[打印]">
                                    <el-col class="line" :span="8">
                                        <el-select v-model="systemnameForm.printstatus" placeholder="请选择">
                                            <el-option label="启用" value="1"></el-option>
                                            <el-option label="隐藏" value="0"></el-option>
                                        </el-select>
                                    </el-col>
                                </el-form-item>
                                <el-form-item label="列表按钮[导出]">
                                    <el-col class="line" :span="8">
                                        <el-select v-model="systemnameForm.exportstatus" placeholder="请选择">
                                            <el-option label="启用" value="1"></el-option>
                                            <el-option label="隐藏" value="0"></el-option>
                                        </el-select>
                                    </el-col>
                                </el-form-item>
                                <el-form-item>
                                    <el-button type="primary" @click="globalTabSave">保存</el-button>
                                </el-form-item>
                            </el-form>
                        </span>
                        <span v-if="globalTabCheck.prop==='systemworkflow'">
                            <el-form ref="systemworkflowForm" :model="systemworkflowForm" label-width="120px">
                                <el-form-item label="历史记录">
                                    <el-col class="line" :span="8">
                                        <el-select v-model="systemworkflowForm.history" placeholder="请选择">
                                            <el-option label="启用" value="1"></el-option>
                                            <el-option label="隐藏" value="0"></el-option>
                                        </el-select>
                                    </el-col>
                                </el-form-item>
                                <el-form-item label="黑名单记录">
                                    <el-col class="line" :span="8">
                                        <el-select v-model="systemworkflowForm.blackname" placeholder="请选择">
                                            <el-option label="启用" value="1"></el-option>
                                            <el-option label="隐藏" value="0"></el-option>
                                        </el-select>
                                    </el-col>
                                </el-form-item>
                                <el-form-item>
                                    <el-button type="primary" @click="globalTabSave">保存</el-button>
                                </el-form-item>
                            </el-form>
                        </span>
                    </el-main>
                </el-container>
            </el-dialog>

        </el-main>
    </el-container>
</template>

<script>
    import {
        api
    } from "@/api/common";
    import {
        getFormConfigData
    } from '@/const/views/system/dev/workflow'
    import {
        getBirtFormConfigData
    } from '@/const/views/system/dev/birt'
    import {
        getJobConfigFormData
    } from '@/const/views/system/dev/jobconfig'
    export default {
        mounted() {
            const s = document.createElement('script');
            s.type = 'text/javascript';
            s.src = 'https://cdn.staticfile.org/Sortable/1.10.0-rc2/Sortable.min.js';
            document.body.appendChild(s);
        },
        watch: {
            formDesignNodeSelection(val) {
                // console.log(val)
                this.$set(this.formDesigntableColumns.column[0], 'dicData', val)
            },
            // formDesignConfigOption(val) {
            //     console.log(val)
            //     this.$set(this.formDesignConfigOptionObject, 'formDesignConfigOption', val)
            //     console.log(this.formDesignConfigOptionObject.formDesignConfigOption)
            // }
        },
        data() {
            return {
                formHackReset: true,
                flowSrc: '',
                formConfig: [], // 表单配置数据
                formValue: {}, // 表单值
                dialogFormVisible: false, // 弹出框显示
                dialogFormTitle: '', // 弹出框标题
                dialogFormVisibleDesign: false, // 弹出框显示
                dialogFormTitleDesign: '', // 弹出框标题
                dialogBirtTitle: '',
                dialogBirtVisible: false,
                nodeTreeData: [],
                checkNode: {},
                detailinnerDialogFormTitle: '',
                detailinnerVisible: false,
                detailFormHackReset: true,
                detailFormValue: {},
                detailFormConfig: [],
                page: {
                    currentPage: 1,
                    total: 0,
                    pageSize: 10
                },
                searchForm: {},
                // searchList: [{
                //     prop: 'keyword',
                //     label: '快捷搜索',
                //     placeholder: '流程名称'
                // }],
                filterForm: {},
                btnList: [{
                    type: "primary",
                    funName: "add",
                    label: "创建",
                }],
                tableData: [],
                tableColumns: {
                    border: true,
                    stripe: false,
                    showHeader: true,
                    index: false,
                    page: true,
                    align: 'left',
                    menuAlign: 'center',
                    addBtn: false,
                    delBtn: false,
                    editBtn: false,
                    menu: true,
                    menuWidth: 650,
                    // filterBtn:true,
                    columnBtn: false,
                    searchMenuSpan: 4,
                    column: [{
                        prop: "wf01001",
                        label: "流程ID"
                    }, {
                        prop: "wf01002",
                        label: "流程名称"
                    }, {
                        prop: "wf01004",
                        label: "状态",
                        slot: true
                    }, {
                        prop: "created_at",
                        label: "创建时间"
                    }, {
                        label: '快捷搜索',
                        prop: 'keyword',
                        search: true,
                        hide: true,
                        searchPlaceholder: '流程名称'
                    }]
                },
                birtbtnList: [{
                    type: "primary",
                    funName: "detailadd",
                    label: "添加",
                }],
                birttableData: [], // 表格数据
                birttableColumns: { // 表格列配置
                    border: true,
                    stripe: false,
                    showHeader: true,
                    index: false,
                    size: 'mini',
                    page: false,
                    align: 'left',
                    menuAlign: 'center',
                    addBtn: false,
                    delBtn: false,
                    editBtn: false,
                    menu: true,
                    menuWidth: '150px',
                    column: [{
                        prop: "wf04003",
                        label: "UUID"
                    }, {
                        prop: "wf04004",
                        label: "报表名称"
                    }, {
                        prop: "wf04007",
                        label: "报表类型",
                        slot: true
                    }, {
                        prop: "wf04008",
                        label: "是否转PDF",
                        slot: true
                    }, {
                        prop: "wf04009",
                        label: "是否单页详情",
                        slot: true
                    }, {
                        prop: "wf04010",
                        label: "状态",
                        slot: true
                    }, {
                        prop: "wf04011",
                        label: "排序",
                    }]
                },
                multiObj: {
                    dynamic: []
                },
                multiOption: {
                    labelWidth: 110,
                    emptyBtn: false,
                    enter: false,
                    submitBtn: false,
                    column: [{
                        label: 'multi配置',
                        prop: 'multi',
                        type: 'dynamic',
                        span: 24,
                        children: {
                            align: 'center',
                            headerAlign: 'center',
                            column: [{
                                width: 100,
                                label: 'key值',
                                prop: "key",
                                type: 'input'
                            }, {
                                width: 340,
                                label: '字段类型[name=0;image=1;age=0]',
                                prop: "field",
                                type: 'input'
                            }]
                        }
                    }, ]
                },
                singleObj: {
                    dynamic: []
                },
                singleOption: {
                    labelWidth: 110,
                    emptyBtn: false,
                    enter: false,
                    submitBtn: false,
                    column: [{
                        label: 'single配置',
                        prop: 'single',
                        type: 'dynamic',
                        span: 24,
                        children: {
                            align: 'center',
                            headerAlign: 'center',
                            column: [{
                                width: 200,
                                label: '字段',
                                prop: "field",
                                type: 'input'
                            }, {
                                width: 200,
                                label: '类型',
                                prop: "type",
                                type: 'switch',
                                dicData: [{
                                    label: '文本',
                                    value: 0
                                }, {
                                    label: '图片',
                                    value: 1
                                }]
                            }]
                        }
                    }]
                },
                // 表单设计
                formDesignTitle: '',
                formDesignVisible: false,
                formDesignRow: {},
                formDesignNodeSelection: [],
                formDesigntableData: [],
                formStatus: 1,
                firstShow: 0,
                formDesigntableColumns: {
                    border: true,
                    stripe: false,
                    showHeader: true,
                    index: false,
                    page: false,
                    align: 'left',
                    menuAlign: 'center',
                    addBtn: true,
                    delBtn: false,
                    editBtn: true,
                    menu: true,
                    menuWidth: 650,
                    columnBtn: false,
                    column: [{
                        prop: "nodeId",
                        label: "所属节点",
                        type: 'select',
                        dicData: this.formDesignNodeSelection,
                        rules: [{
                            required: true,
                            message: "所属节点不能为空",
                        }]
                    }, {
                        prop: "formName",
                        label: "表单名称",
                        rules: [{
                            required: true,
                            message: "表单名称不能为空",
                        }]
                    }, {
                        prop: "firstShow",
                        label: "默认显示",
                        slot: true,
                        value: 0,
                        formslot: true,
                        rules: [{
                            required: true
                        }]
                    }, {
                        prop: "formStatus",
                        label: "状态",
                        slot: true,
                        value: 1,
                        formslot: true,
                        rules: [{
                            required: true
                        }]
                    }, {
                        prop: "created_at",
                        label: "创建时间",
                        addDisplay: false,
                        editDisplay: false,
                    }, {
                        prop: "formId",
                        label: "表单ID",
                        addDisplay: false,
                        editDisplay: false,
                        hide: true
                    }]
                },
                formDesignConfigTitle: '',
                formDesignConfigVisible: false,
                // formDesignConfigOptionObject: {
                //     formDesignConfigOption: {}
                // },
                formDesignConfigOption: {},
                formDesignConfigRow: {},
                
                // 业务表设计
                jobTitle: '',
                jobVisible: false,
                jobTreeData: [],
                jobConfigForm: [],
                jobConfigFormTitle: '',
                jobConfigVisible: false,
                jobConfigFormHackReset: false,
                jobConfigFormValue: {},
                jobFlowData: {},
                jobTreeNode: {},
                jobConfigbtnList: [{
                    type: "primary",
                    funName: "jobConfigAddRowSingle",
                    label: "添加",
                }, {
                    type: "primary",
                    funName: "jobConfigAddRow",
                    label: "添加5条",
                }],
                jobConfigAvueData: [],
                jobConfigAvueOption: {
                    addBtn: false,
                    editBtn: false,
                    addRowBtn: false,
                    cellBtn: true,
                    refreshBtn: false,
                    columnBtn: false,
                    menuWidth: 250,
                    column: [{
                        label: '字段名',
                        prop: 'columnName',
                        cell: false,
                    }, {
                        label: '*注释*',
                        prop: 'comment',
                        cell: true,
                        rules: [{
                            required: true,
                            message: '请输入注释',
                            trigger: 'blur'
                        }]
                    }, {
                        label: '*字段类型*',
                        prop: 'columnType',
                        type: 'select',
                        cell: true,
                        dicData: [{
                            label: 'varchar',
                            value: 'varchar'
                        }, {
                            label: 'text',
                            value: 'text'
                        }, {
                            label: 'decimal',
                            value: 'decimal'
                        }, {
                            label: 'bigint',
                            value: 'bigint'
                        }, {
                            label: 'int',
                            value: 'int'
                        }, {
                            label: 'tinyint',
                            value: 'tinyint'
                        }],
                        rules: [{
                            required: true,
                            message: '请选择字段类型',
                            trigger: 'blur'
                        }]
                    }, {
                        label: '*字段长度*',
                        prop: 'columnLength',
                        cell: true,
                        rules: [{
                            required: true,
                            message: '请输入字段长度',
                            trigger: 'blur'
                        }]
                    }, {
                        label: '小数点',
                        prop: 'columnDig',
                        cell: true,
                        value: '0'
                    }, {
                        label: '代码类型',
                        prop: 'codeType',
                        type: 'select',
                        cell: true,
                        dicData: [{
                            label: '系统字典',
                            value: 1
                        }, {
                            label: '公司字典',
                            value: 2
                        }]
                    }, {
                        label: '系统编码',
                        prop: 'sysNumber',
                        type: 'select',
                        cell: true,
                        filterable: true,
                        dicUrl: '/wf/api/wf/getSystemDicts',
                    }, {
                        label: '公司编码',
                        prop: 'comNumber',
                        type: 'select',
                        cell: true,
                        filterable: true,
                        dicUrl: '/wf/api/wf/getComDicts',
                    }]
                },
                jobIncream: {
                    'prefix': '',
                    'maxnum': ''
                },
                jobState: [],
                nodeTitle: '',
                nodeVisible: false,
                nodeFlowData: {},
                nodeData: [],
                nodeTabCheck: {
                    prop: ''
                },
                nodeMenuCheck: {},
                nodeSetOption: {
                    column: [{
                            label: '列表字段选择',
                            prop: 'step1',
                        }, {
                            label: '列表字段设置',
                            prop: 'step2',
                        }
                        /* , {
                                                label: '系统内置配置',
                                                prop: 'step3',
                                            } */
                        , {
                            label: '审核信息配置',
                            prop: 'step4',
                            disabled: true,
                        }
                    ]
                },
                // lijianlin
                examConfigForm: {
                    examResult: '',
                    examDate: '',
                    examReason: '',
                    examPerson: ''
                },
                examConfigRules: {
                    examResult: {
                        required: true,
                        message: '审核结果不能为空',
                        trigger: 'blur'
                    },
                    examDate: {
                        required: true,
                        message: '审核时间不能为空',
                        trigger: 'blur'
                    },
                    examReason: {
                        required: true,
                        message: '审核意见不能为空',
                        trigger: 'blur'
                    },
                    examPerson: {
                        required: true,
                        message: '审核人员不能为空',
                        trigger: 'blur'
                    },
                },
                examColumns: [],

                nodeColumnData: [],
                nodeColumnValue: [],
                nodeColumnList: [],
                nodeColumnListOption: {
                    sortable: true,
                    addBtn: false,
                    editBtn: false,
                    delBtn: false,
                    addRowBtn: false,
                    cellBtn: true,
                    refreshBtn: false,
                    columnBtn: false,
                    rowKey: 'key',
                    menuWidth: 250,
                    column: [{
                        label: '原字段中文名',
                        prop: 'origin',
                        cell: false,
                    }, {
                        label: '字段名',
                        prop: 'key',
                        cell: false,
                    }, {
                        label: '字段列表别名',
                        prop: 'label',
                        cell: true,
                    }]
                },
                // 全局设置
                globalTitle: '',
                globalVisible: false,
                globalFlowData: {},
                globalTabCheck: {
                    prop: ''
                },
                globalSetOption: {
                    column: [{
                            label: '订单编码设置',
                            prop: 'ordernumber',
                        }, {
                            label: '内置显隐',
                            prop: 'systemname',
                        }
                        /* , {
                                                label: '报表控制',
                                                prop: 'birtcontrol',
                                            } */
                        , {
                            label: '流程附加',
                            prop: 'systemworkflow',
                        }
                    ]
                },
                ordernumberForm: {
                    type: 'sysnum',
                    prefix: '',
                    connectp: '0',
                    date: 'ymd',
                    connectd: '0',
                    randnum: '3'
                },
                systemnameKcolumn: [],
                systemnameForm: {
                    namestatus: '1',
                    namekey: '',
                    nameshow: '',
                    numberstatus: '1',
                    numberkey: '',
                    numbershow: '',
                    keywordstatus: '1',
                    keywordplaceholder: '',
                    printstatus: '0',
                    exportstatus: '0',
                },
                systemworkflowForm: {
                    history: '0',
                    blackname: '0'
                },
            }
        },
        created() {
            this.getTableList();
            this.getFormConfig();
        },
        methods: {
            upgradesql(row) {
                let url = api.getWorkFlowUpgradeScript,
                    _this = this,
                    params = {
                        flowId: row.wf01001,
                    }
                
                _this.axios.post(url, params, {
                    responseType: 'blob'
                }).then(response => {
                    let blob = new Blob([response.data], {
                        type: 'application/octet-stream;charset=utf-8'
                    })
                    let filename = decodeURI(response.headers['content-disposition'].split('=')[1]).replace(
                        /^"*|"*$/g, '')
                    if ('download' in document.createElement('a')) { // 非IE下载
                        const elink = document.createElement('a')
                        elink.download = filename
                        elink.style.display = 'none'
                        elink.href = URL.createObjectURL(blob)
                        document.body.appendChild(elink)
                        elink.click()
                        document.body.removeChild(elink)
                        window.URL.revokeObjectURL(elink.href) //释放掉blob对象
                    } else { // IE10+下载
                        navigator.msSaveBlob(blob, filename)
                    }
                }).catch(() => {
                    _this.$message({
                        showClose: false,
                        message: '下载出错',
                        type: 'error'
                    })
                })
            },
            processsql(row) {
                let url = api.getWorkFlowProcessScript,
                    _this = this,
                    params = {
                        flowId: row.wf01001,
                    }

                _this.axios.post(url, params, {
                    responseType: 'blob'
                }).then(response => {
                    let blob = new Blob([response.data], {
                        type: 'application/octet-stream;charset=utf-8'
                    })
                    let filename = decodeURI(response.headers['content-disposition'].split('=')[1]).replace(
                        /^"*|"*$/g, '')
                    if ('download' in document.createElement('a')) { // 非IE下载
                        const elink = document.createElement('a')
                        elink.download = filename
                        elink.style.display = 'none'
                        elink.href = URL.createObjectURL(blob)
                        document.body.appendChild(elink)
                        elink.click()
                        document.body.removeChild(elink)
                        window.URL.revokeObjectURL(elink.href) //释放掉blob对象
                    } else { // IE10+下载
                        navigator.msSaveBlob(blob, filename)
                    }
                }).catch(() => {
                    _this.$message({
                        showClose: false,
                        message: '下载出错',
                        type: 'error'
                    })
                })
            },
            // 表格刷新
            refresh() {
                this.getTableList();
            },
            // 搜索
            searchChange(params, done) {
                this.page.currentPage = 1
                this.getTableList(params)
                Object.assign(this.searchForm, params)
                done()
            },
            // 搜索清空
            searchReset() {
                this.page.currentPage = 1
                this.$set(this.searchForm, 'keyword', '')
                this.getTableList()
            },
            // 表格过滤（高级搜索）
            filterChange(result) {
                this.getTableList(result)
                this.filterForm = result
            },
            // 分页
            sizeChange(val) {
                this.page.currentPage = 1
                this.page.pageSize = val
                this.getTableList();
            },
            // 当前页
            currentChange(val) {
                this.page.currentPage = val
                this.getTableList();
            },
            // 绑定弹窗子组件的关闭
            handleCloseBindDialogForm() {
                this.dialogFormVisible = false
                this.dialogFormTitle = ''
            },
            handleCloseBindDialogDesign() {
                this.dialogFormVisibleDesign = false
                this.dialogFormTitleDesign = ''
                this.flowSrc = ''
            },
            handleCloseBirtDialog() {
                this.dialogBirtTitle = ''
                this.dialogBirtVisible = false
                this.checkNode = {}
                this.birttableData = []
                this.nodeTreeData = []
            },
            handleCloseBindDetailDialogForm() {
                this.detailinnerDialogFormTitle = ''
                this.detailinnerVisible = false
            },
            // 获取表格数据
            getTableList(where) {
                let _this = this,
                    params = {
                        page: this.page.currentPage,
                        limit: this.page.pageSize,
                    }
                params = Object.assign({}, params, this.searchForm)
                params = Object.assign({}, params, this.filterForm)
                if (where) {
                    params = Object.assign({}, params, where)
                }
                _this.axios.post(api.getWorkFlowList, params).then((res) => {
                    if (res.data.code == 10000) {
                        _this.tableData = res.data.data.list
                        _this.page.total = res.data.data.count
                    } else {
                        _this.tableData = []
                        _this.page.total = 0
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                }).catch((err) => {
                    _this.tableData = []
                    _this.page.total = 0
                    console.log('调用失败', err)
                })
            },
            // 获取表单配置
            getFormConfig() {
                var _this = this
                _this.formConfig = getFormConfigData()
            },
            // 按钮点击（转发）
            btnclick(func) {
                this[func]()
            },
            // 启用
            enabled(row) {
                let url = api.workFlowSts,
                    params = {
                        flowId: '',
                        status: 1
                    },
                    _this = this

                params.flowId = row.wf01001

                _this.$confirm('是否确认启用流程?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    _this.handleAxiosFun(url, params)
                }).catch(() => {});
            },
            // 禁用
            disabled(row) {
                let url = api.workFlowSts,
                    params = {
                        flowId: '',
                        status: 0
                    },
                    _this = this

                params.flowId = row.wf01001

                _this.$confirm('是否确认禁用流程?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    _this.handleAxiosFun(url, params)
                }).catch(() => {});
            },
            // 添加
            add() {
                this.$set(this.formConfig[0], 'disabled', false)
                this.formValue = {}
                this.formHackReset = false
                this.$nextTick(() => {
                    this.formHackReset = true
                })
                this.dialogFormVisible = true
                this.dialogFormTitle = '创建流程'
            },
            rowbtnclick(func, row) {
                this[func](row)
            },
            // 编辑
            async edit(row) {
                let _this = this
                _this.axios.post(api.getWorkFlowByFlowId, {
                    flowId: row.wf01001
                }).then((res) => {
                    if (res.data.code == 10000) {
                        _this.$set(_this.formConfig[0], 'disabled', false)
                        _this.formValue = Object.assign({}, res.data.data)
                        _this.dialogFormVisible = true
                        _this.dialogFormTitle = '编辑【' + row.wf01002 + '】流程'
                        _this.formHackReset = false
                        _this.$nextTick(() => {
                            _this.formHackReset = true
                        })
                    } else {
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        })
                    }
                }).catch((err) => {
                    _this.$message({
                        showClose: false,
                        message: '获取流程详情失败！',
                        type: 'error'
                    })
                    console.log('调用失败', err)
                })
            },
            design(row) {
                this.dialogFormVisibleDesign = true
                this.dialogFormTitleDesign = '编辑【' + row.wf01002 + '】流程'
                this.flowSrc = api.WEBSITE + "/designer/" + row.wf01001
            },
            async birt(row) {
                this.dialogBirtVisible = true
                this.dialogBirtTitle = '报表设计【' + row.wf01002 + ' / ' + row.wf01001 + '】'
                this.getBirtTreeData(row.wf01001)
                this.detailFormConfig = getBirtFormConfigData()
            },
            getBirtTreeData(flowId) {
                let _this = this,
                    params = {
                        flowId: flowId
                    }
                _this.axios.post(api.getWorkNodesTreeByFlowId, params).then((res) => {
                    if (res.data.code == 10000) {
                        _this.nodeTreeData = res.data.data
                    } else {
                        _this.nodeTreeData = []
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                }).catch((err) => {
                    _this.nodeTreeData = []
                    console.log('调用失败', err)
                })
            },
            handleNodeClick(node) {
                if (node.type === 'flow') {
                    return false;
                }
                this.checkNode = node
                this.getBirtList()
            },
            birtrefresh() {
                this.getBirtList()
            },
            getBirtList() {
                let _this = this,
                    params = {
                        flowId: this.checkNode.flowId,
                        nodeId: this.checkNode.id
                    }
                params = Object.assign({}, params, this.searchForm)
                params = Object.assign({}, params, this.filterForm)
                _this.axios.post(api.getBirtList, params).then((res) => {
                    console.log(res)
                    if (res.data.code == 10000) {
                        _this.birttableData = res.data.data
                    } else {
                        _this.birttableData = []
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                }).catch((err) => {
                    _this.birttableData = []
                    console.log('调用失败', err)
                })
            },
            detailadd() {
                if (JSON.stringify(this.checkNode) == '{}') {
                    this.$message({
                        showClose: false,
                        message: '请选择需要操作的节点！',
                        type: 'info'
                    });
                    return false;
                }
                this.$set(this.detailFormConfig[0], 'disabled', false)
                this.detailFormValue = {}
                this.detailFormHackReset = false
                this.$nextTick(() => {
                    this.detailFormHackReset = true
                })
                this.singleObj.single = []
                this.multiObj.multi = []
                this.detailinnerVisible = true
                this.detailinnerDialogFormTitle = '创建报表'
            },
            detailenabled(row) {
                let url = api.birtSts,
                    params = {
                        uuid: row.wf04003,
                        status: 1
                    },
                    _this = this
                let _sucess_callback = function() {
                    _this.getBirtList()
                }

                _this.$confirm('是否确认启用报表?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    _this.handleAxiosFun(url, params, _sucess_callback)
                }).catch(() => {});
            },
            detaildisabled(row) {
                let url = api.birtSts,
                    params = {
                        uuid: row.wf04003,
                        status: 0
                    },
                    _this = this

                let _sucess_callback = function() {
                    _this.getBirtList()
                }

                _this.$confirm('是否确认禁用报表?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    _this.handleAxiosFun(url, params, _sucess_callback)
                }).catch(() => {});
            },
            detaildel(row) {
                let url = api.birtRmv,
                    _this = this,
                    params = {
                        uuid: row.wf04003,
                    }

                let _sucess_callback = function() {
                    _this.getBirtList()
                }

                _this.$confirm('该操作会永久删除该报表记录, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    _this.handleAxiosFun(url, params, _sucess_callback)
                }).catch(() => {});
            },
            detailsimulation(row) {
                let url = api.birtSimulation,
                    _this = this,
                    params = {
                        uuid: row.wf04003,
                    }

                _this.axios.post(url, params, {
                    responseType: 'blob'
                }).then(response => {
                    console.log(response)
                    let blob = new Blob([response.data], {
                        type: 'application/octet-stream;charset=utf-8'
                    })
                    let filename = decodeURI(response.headers['content-disposition'].split('=')[1]).replace(
                        /^"*|"*$/g, '')
                    if ('download' in document.createElement('a')) { // 非IE下载
                        const elink = document.createElement('a')
                        elink.download = filename
                        elink.style.display = 'none'
                        elink.href = URL.createObjectURL(blob)
                        document.body.appendChild(elink)
                        elink.click()
                        document.body.removeChild(elink)
                        window.URL.revokeObjectURL(elink.href) //释放掉blob对象
                    } else { // IE10+下载
                        navigator.msSaveBlob(blob, filename)
                    }
                }).catch(() => {
                    _this.$message({
                        showClose: false,
                        message: '模拟运行失败',
                        type: 'error'
                    })
                })

                // _this.handleAxiosFun(url, params)
            },
            detailedit(row) {
                let _this = this
                _this.axios.post(api.getBirtByUuid, {
                    uuid: row.wf04003,
                }).then((res) => {
                    if (res.data.code == 10000) {
                        _this.singleObj.single = res.data.data.single
                        _this.multiObj.multi = res.data.data.multi
                        _this.detailFormValue = Object.assign({}, res.data.data)
                        _this.detailFormHackReset = false
                        _this.$nextTick(() => {
                            _this.detailFormHackReset = true
                        })
                        _this.detailinnerVisible = true
                        _this.detailinnerDialogFormTitle = '编辑【' + row.wf04004 + '】报表'
                    } else {
                        _this.detailFormValue = {}
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        })
                    }
                }).catch((err) => {
                    _this.detailFormValue = {}
                    _this.$message({
                        showClose: false,
                        message: '获取报表详情失败！',
                        type: 'error'
                    })
                    console.log('调用失败', err)
                })
            },
            detailsave() {
                let _this = this,
                    url = api.birtCrd,
                    params = this.detailFormValue
                // console.log(params)
                if (params['id'] && params['id'] != '') {
                    url = api.birtEdt
                }

                let _sucess_callback = function() {
                    _this.getBirtList()
                    _this.handleCloseBindDetailDialogForm()
                }

                params['single'] = _this.singleObj.single
                params['multi'] = _this.multiObj.multi
                params['flowId'] = _this.checkNode.flowId
                params['nodeId'] = _this.checkNode.id

                _this.handleAxiosFun(url, params, _sucess_callback)
            },
            // 删除
            //     del (row) {
            //       let url = api.workFlowRmv,
            //           _this = this, 
            //           params = {
            //             id: row.id
            //           }

            //       _this.$confirm('该操作会永久删除该角色, 是否继续?', '提示', {
            //         confirmButtonText: '确定',
            //         cancelButtonText: '取消',
            //         type: 'warning'
            //       }).then (() => {
            //         _this.handleAxiosFun(url, params)
            //       }).catch(() => {});
            //     },     
            // 保存
            save() {
                let _this = this,
                    url = api.workFlowCrd,
                    params = this.formValue

                if (params['id'] && params['id'] != '') {
                    url = api.workFlowEdt
                }

                _this.handleAxiosFun(url, params, )
            },
            // axios接口请求
            handleAxiosFun(url, params, _sucess_callback, _fail_callback) {
                let _this = this

                _this.axios.post(url, params).then((res) => {
                    if (res.data.code == 10000) {
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'success'
                        });
                        if (_sucess_callback && typeof _sucess_callback === 'function') {
                            _sucess_callback()
                        } else {
                            _this.getTableList()
                            _this.handleCloseBindDialogForm()
                        }
                    } else {
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                        if (_fail_callback && typeof _fail_callback === 'function') {
                            _fail_callback()
                        }
                    }
                }).catch(() => {
                    _this.$message({
                        showClose: false,
                        message: '调用失败',
                        type: 'error'
                    });
                })
            },
            // 表单设计
            formdesign(row) {
                this.formDesignVisible = true
                this.formDesignTitle = '表单设计【' + row.wf01002 + ' / ' + row.wf01001 + '】'
                this.formDesignRow = row
                this.getFormDesignList()
            },
            handleCloseFormDesign() {
                this.formDesignTitle = ''
                this.formDesignVisible = false
                this.formDesigntableData = []
                this.formDesignNodeSelection = []
            },
            formDesignConfig(row) {
                let _this = this,
                    params = {
                        formId: row.formId
                    }
                _this.axios.post(api.getFormDesignConfigByFormId, params).then((res) => {
                    if (res.data.code == 10000) {
                        // console.log(res.data.data)
                        _this.formDesignConfigOption = res.data.data
                        _this.formDesignConfigRow = row
                        this.formDesignConfigVisible = true
                        this.formDesignConfigTitle = '表单设计【' + row.formName + '】'
                        console.log(_this.formDesignConfigOption)
                    } else {
                        _this.formDesignConfigRow = {}
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                }).catch((err) => {
                    _this.formDesignConfigRow = {}
                    console.log('调用失败', err)
                })
            },
            getFormDesignList() {
                let _this = this,
                    params = {
                        flowId: this.formDesignRow.wf01001,
                    }
                _this.axios.post(api.getFormDesignList, params).then((res) => {
                    if (res.data.code == 10000) {
                        _this.formDesigntableData = res.data.data.list
                        _this.formDesignNodeSelection = res.data.data.nodeSelection
                    } else {
                        _this.formDesigntableData = []
                        _this.formDesignNodeSelection = []
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                }).catch((err) => {
                    _this.formDesigntableData = []
                    _this.formDesignNodeSelection = []
                    console.log('调用失败', err)
                })
            },
            handleFormDesignRefresh() {
                this.getFormDesignList()
            },
            handleFormDesignSave(row, done, loading) {
                row['flowId'] = this.formDesignRow.wf01001
                this.handleAxiosFunFromDesign(api.formDesignConfigCrd, row, done, loading)
            },
            handleFormDesignUpdate(row, index, done, loading) {
                this.handleAxiosFunFromDesign(api.formDesignConfigEdt, row, done, loading)
            },
            formDesignEnabled(row) {
                const params = {
                    formId: row.formId,
                    formStatus: 1,
                    flowId: row.flowId
                }
                this.handleAxiosFunFromDesign(api.formDesignConfigSts, params)
            },
            formDesignDisabled(row) {
                const params = {
                    formId: row.formId,
                    formStatus: 0,
                    flowId: row.flowId
                }
                this.handleAxiosFunFromDesign(api.formDesignConfigSts, params)
            },
            handleFormDesignRemove(row) {
                const params = {
                    formId: row.formId,
                    flowId: row.flowId
                }
                var _this = this
                _this.$confirm('是否确认删除#' + row.formName, '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(function() {
                    _this.handleAxiosFunFromDesign(api.formDesignConfigRmv, params)
                }).catch(() => {})
            },
            handleAxiosFunFromDesign(url, params, done, loading) {
                const _this = this
                _this.axios.post(url, params).then((res) => {
                    if (res.data.code === 10000) {
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'success'
                        })
                        _this.getFormDesignList()
                        if (done) {
                            done()
                        }
                    } else {
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        })
                        if (loading) {
                            loading()
                        }
                    }
                }).catch(() => {
                    _this.$message({
                        showClose: false,
                        message: '网络连接失败，请重试！',
                        type: 'error'
                    })
                    if (loading) {
                        loading()
                    }
                })
            },
            handleCloseFormDesignConfig() {
                this.formDesignConfigTitle = ''
                this.formDesignConfigVisible = false
                // this.formDesignConfigOptionObject.formDesignConfigOption = {}
                this.formDesignConfigOption = {}
                this.formDesignConfigRow = {}
            },
            handleSubmitFormDesign(val) {
                // console.log(val)
                let _this = this,
                    params = {
                        flowId: this.formDesignConfigRow.flowId,
                        formId: this.formDesignConfigRow.formId,
                        formConfig: val
                    }
                _this.axios.post(api.formDesignConfigSave, params).then((res) => {
                    if (res.data.code === 10000) {
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'success'
                        })
                    } else {
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        })
                    }
                }).catch(() => {
                    _this.$message({
                        showClose: false,
                        message: '网络连接失败，请重试！',
                        type: 'error'
                    })
                })
            },
            
            async jobset(row) {
                this.jobVisible = true
                this.jobTitle = '业务表设计【' + row.wf01002 + ' / ' + row.wf01001 + '】'
                this.jobFlowData = {
                    flowId: row.wf01001
                }
                this.getJobTreeData(row.wf01001)
                this.jobConfigForm = getJobConfigFormData()
            },
            handleCloseJob() {
                this.jobTitle = ''
                this.jobVisible = false
                this.jobFlowData = {}
                this.jobTreeNode = {}
            },
            getJobTreeData(flowId) {
                let _this = this,
                    params = {
                        flowId: flowId
                    }
                _this.axios.post(api.getJobConfigsTreeByFlowId, params).then((res) => {
                    if (res.data.code == 10000) {
                        _this.jobTreeData = res.data.data
                    } else {
                        _this.jobTreeData = []
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                }).catch((err) => {
                    _this.jobTreeData = []
                    console.log('调用失败', err)
                })
            },
            createJob() {
                this.$set(this.jobConfigForm[0], 'disabled', false)
                for (let index = 0; index < this.jobConfigForm[0].formItemList.length; index++) {
                    const element = this.jobConfigForm[0].formItemList[index];
                    if (element.key === 'table') {
                        this.$set(this.jobConfigForm[0].formItemList[index], 'disabled', false)
                    }
                }
                this.jobConfigFormValue = {}
                this.jobConfigFormHackReset = false
                this.$nextTick(() => {
                    this.jobConfigFormHackReset = true
                })
                this.jobConfigVisible = true
                this.jobConfigFormTitle = '创建业务表'
            },
            editJob(node, row) {
                let _this = this;
                _this.$set(_this.jobConfigForm[0], 'disabled', false)
                for (let index = 0; index < _this.jobConfigForm[0].formItemList.length; index++) {
                    const element = _this.jobConfigForm[0].formItemList[index];
                    if (element.key === 'table') {
                        _this.$set(_this.jobConfigForm[0].formItemList[index], 'disabled', true)
                    }
                }

                _this.jobConfigFormValue = Object.assign({}, row)
                _this.jobConfigVisible = true
                _this.jobConfigFormTitle = '编辑【' + row.label + '】业务表'
                _this.jobConfigFormHackReset = false
                _this.$nextTick(() => {
                    _this.jobConfigFormHackReset = true
                })
            },
            removeJob(node, row) {
                let _this = this,
                    param = {};
                param['flowId'] = row.flowId
                param['table'] = row.table

                _this.$confirm('确定要删除[' + row.label + ']表么，相关数据将会全部删除?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    _this.axios.post(api.jobTableRmv, param).then((res) => {
                        if (res.data.code == 10000) {
                            _this.$message({
                                showClose: false,
                                message: res.data.message,
                                type: 'success'
                            });
                            _this.getJobTreeData(row.flowId)
                            _this.jobTreeNode = {}
                            _this.jobIncream.prefix = ''
                            _this.jobIncream.maxnum = ''
                            _this.jobConfigAvueData = []
                        } else {
                            _this.$message({
                                showClose: false,
                                message: res.data.message,
                                type: 'error'
                            });
                        }
                    }).catch((err) => {
                        // done()
                        console.log('调用失败', err)
                    })
                }).catch(() => {});
            },
            handleCloseBindJobConfigForm() {
                this.jobConfigFormTitle = ''
                this.jobConfigVisible = false
            },
            jobConfigSave() {
                let _this = this,
                    url = api.jobConfigCrd,
                    params = this.jobConfigFormValue
                params['flowId'] = _this.jobFlowData.flowId
                if (params['id'] && params['id'] != '') {
                    url = api.jobConfigEdt
                }

                let _sucess_callback = function() {
                    _this.getJobTreeData(_this.jobFlowData.flowId)
                    _this.handleCloseBindJobConfigForm()
                }

                _this.handleAxiosFun(url, params, _sucess_callback)
            },
            handleJobClick(node) {
                if (node.system == '1') {
                    return false;
                }

                let _this = this;
                let params = {};
                params['flowId'] = node.flowId;
                params['table'] = node.table;
                _this.axios.post(api.getJobConfigsMaxColumn, params).then((res) => {
                    _this.jobState = []
                    if (res.data.code == 10000) {
                        _this.jobTreeNode = node
                        _this.jobIncream.prefix = res.data.data.prefix
                        _this.jobIncream.maxnum = res.data.data.maxnum
                        _this.getJobConfigsList()
                    } else {
                        _this.jobTreeNode = {}
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                }).catch((err) => {
                    _this.jobTreeNode = {}
                    console.log('调用失败', err)
                })
            },
            getJobConfigsList() {
                let _this = this,
                    params = {
                        flowId: this.jobTreeNode.flowId,
                        table: this.jobTreeNode.table
                    }
                _this.axios.post(api.getJobConfigsList, params).then((res) => {
                    if (res.data.code == 10000) {
                        _this.jobConfigAvueData = res.data.data
                    } else {
                        _this.jobConfigAvueData = []
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                }).catch((err) => {
                    _this.jobConfigAvueData = []
                    console.log('调用失败', err)
                })
            },
            jobConfigAddUpdate(form, index, done, loading) {
                let _this = this,
                    param = form;
                param['flowId'] = _this.jobTreeNode.flowId
                param['table'] = _this.jobTreeNode.table
                loading()
                _this.axios.post(api.jobConfigSave, param).then((res) => {
                    if (res.data.code == 10000) {

                    } else {
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                    done()
                }).catch((err) => {
                    done()
                    console.log('调用失败', err)
                })
            },
            jobConfigDel(row, index) {
                let _this = this,
                    param = {};
                param['flowId'] = _this.jobTreeNode.flowId
                param['table'] = _this.jobTreeNode.table
                param['column'] = row.columnName

                _this.$confirm('确定要删除[' + row.comment + ']?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    _this.axios.post(api.jobConfigRmv, param).then((res) => {
                        if (res.data.code == 10000) {
                            _this.jobConfigAvueData.splice(index, 1)
                            _this.$message({
                                showClose: false,
                                message: res.data.message,
                                type: 'success'
                            });
                        } else {
                            _this.$message({
                                showClose: false,
                                message: res.data.message,
                                type: 'error'
                            });
                        }
                    }).catch((err) => {
                        // done()
                        console.log('调用失败', err)
                    })
                }).catch(() => {});
            },
            jobConfigAddRowSingle() {
                if (JSON.stringify(this.jobTreeNode) == '{}') {
                    this.$message({
                        showClose: false,
                        message: '请选择需要操作的节点！',
                        type: 'info'
                    });
                    return false;
                }
                let number = this.getIncremColumn()
                this.$refs.jobConfigCrud.rowCellAdd({
                    columnName: number
                });
            },
            getIncremColumn() {
                if (this.jobState.length > 0) {
                    console.log(222)
                } else {
                    var number = this.jobIncream.prefix + this.jobIncream.maxnum

                    let n = this.jobIncream.maxnum.length
                    let num = parseInt(parseInt(this.jobIncream.maxnum) + 1)
                    var maxnum = (Array(n).join(0) + num).slice(-n);
                    this.jobIncream.maxnum = maxnum
                    return number;
                }
            },
            jobConfigAddRow() {
                if (JSON.stringify(this.jobTreeNode) == '{}') {
                    this.$message({
                        showClose: false,
                        message: '请选择需要操作的节点！',
                        type: 'info'
                    });
                    return false;
                }
                this.$message.success('正在添加，请稍后')
                setTimeout(() => {
                    for (let i = 0; i < 5; i++) {
                        let number = this.getIncremColumn()
                        this.$refs.jobConfigCrud.rowCellAdd({
                            columnName: number
                        });
                    }
                }, 500)
            },
            nodeset(row) {
                this.nodeVisible = true
                this.nodeTitle = '节点配置【' + row.wf01002 + ' / ' + row.wf01001 + '】'
                this.nodeFlowData = {
                    flowId: row.wf01001
                }
                this.getWorkNodes()
                // this.jobConfigForm = getJobConfigFormData()
            },
            handleCloseNode() {
                this.nodeTitle = ''
                this.nodeVisible = false
                this.nodeFlowData = {}
            },
            getWorkNodes() {
                let _this = this,
                    params = {
                        flowId: this.nodeFlowData.flowId,
                    }
                _this.axios.post(api.getWorkNodeByFlowId, params).then((res) => {
                    if (res.data.code == 10000) {
                        _this.nodeData = res.data.data
                        // console.log(_this.nodeData)
                    } else {
                        _this.nodeData = []
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                }).catch((err) => {
                    _this.nodeData = []
                    console.log('调用失败', err)
                })
            },
            nodeSetHandleChange(column) {
                if (JSON.stringify(this.nodeMenuCheck) == '{}') {
                    this.$message({
                        showClose: false,
                        message: '请选择需要操作的节点！',
                        type: 'info'
                    });
                    return false;
                }

                this.nodeTabCheck = column
                // console.log(this.nodeTabCheck)
                if (column.prop !== 'step4') {
                    this.getNodeColumns()
                } else {
                    this.getNodeColumnExamConfig()
                }
            },
            getNodeColumnExamConfig() {
                let _this = this,
                    params = {
                        flowId: this.nodeMenuCheck.wf02001,
                        nodeId: this.nodeMenuCheck.wf02002,
                    }
                _this.axios.post(api.getNodeColumnExamConfig, params).then((res) => {
                    if (res.data.code == 10000) {
                        _this.examConfigForm = Object.assign({}, res.data.data.examConfig)
                        _this.examColumns = res.data.data.examColumns
                    } else {
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                }).catch(() => {})
            },
            examConfigSave() {
                let _this = this,
                    url = api.nodeColumnsConfigSave,
                    params = {}

                params['flowId'] = _this.nodeMenuCheck.wf02001
                params['nodeId'] = _this.nodeMenuCheck.wf02002
                params['target'] = _this.examConfigForm
                params['type'] = 4

                _this.$refs['examConfigForm'].validate((valid) => {
                    if (valid) {
                        console.log(params)
                        let _sucess_callback = function() {
                            _this.getNodeColumnExamConfig()
                        }
                        _this.handleAxiosFun(url, params, _sucess_callback)
                    } else {
                        return false;
                    }
                });

            },
            nodeSetCheck(type, item) {
                this.nodeMenuCheck = item
                this.nodeTabCheck = this.nodeSetOption.column[0]
                // console.log(this.nodeSetOption.column.length - 1)
                if (item.wf02005 == 1) {
                    this.nodeSetOption.column[this.nodeSetOption.column.length - 1].disabled = false
                } else {
                    this.nodeSetOption.column[this.nodeSetOption.column.length - 1].disabled = true
                }
                // 获取数据
                this.getNodeColumns()
            },
            getNodeColumns() {
                let _this = this,
                    params = {
                        flowId: this.nodeMenuCheck.wf02001,
                        nodeId: this.nodeMenuCheck.wf02002,
                    }
                _this.axios.post(api.getNodeColumnsConfig, params).then((res) => {
                    if (res.data.code == 10000) {
                        _this.nodeColumnData = res.data.data.source
                        _this.nodeColumnValue = res.data.data.target
                        _this.nodeColumnList = res.data.data.targetList
                    } else {
                        _this.nodeColumnData = []
                        _this.nodeColumnValue = []
                        _this.nodeColumnList = []
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                }).catch((err) => {
                    _this.nodeColumnData = []
                    _this.nodeColumnValue = []
                    _this.nodeColumnList = []
                    console.log('调用失败', err)
                })
            },
            nodeColumnListUpdate(form, index, done, loading) {
                let _this = this,
                    url = api.nodeColumnsConfigSave,
                    param = {}
                param['flowId'] = _this.nodeMenuCheck.wf02001
                param['nodeId'] = _this.nodeMenuCheck.wf02002
                param['target'] = _this.nodeColumnList
                param['type'] = 2
                loading()
                _this.axios.post(url, param).then((res) => {
                    if (res.data.code == 10000) {
                        _this.getNodeColumns()
                    } else {
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                    done()
                }).catch((err) => {
                    done()
                    console.log('调用失败', err)
                })
            },
            nodeColumnListOrderSave() {
                if (this.nodeColumnList.length === 0) {
                    this.$message({
                        showClose: false,
                        message: '无需保存的数据',
                        type: 'info'
                    });
                    return false;
                }

                let _this = this,
                    url = api.nodeColumnsConfigSave,
                    params = {}

                params['flowId'] = _this.nodeMenuCheck.wf02001
                params['nodeId'] = _this.nodeMenuCheck.wf02002
                params['target'] = _this.nodeColumnList
                params['type'] = 2

                let _sucess_callback = function() {
                    _this.getNodeColumns()
                }

                _this.handleAxiosFun(url, params, _sucess_callback)
            },
            nodeColumnListSortableChange(oldindex, newindex, row, list) {
                this.nodeColumnList = []
                this.$nextTick(() => {
                    this.nodeColumnList = list;
                })
            },
            nodeColumnSave(type) {
                let _this = this,
                    url = api.nodeColumnsConfigSave,
                    params = {}

                params['flowId'] = _this.nodeMenuCheck.wf02001
                params['nodeId'] = _this.nodeMenuCheck.wf02002
                params['target'] = _this.nodeColumnValue
                params['type'] = type

                let _sucess_callback = function() {
                    _this.getNodeColumns()
                }

                _this.handleAxiosFun(url, params, _sucess_callback)
            },

            // 全局配置开始
            globalset(row) {
                this.globalVisible = true
                this.globalTitle = '全局配置【' + row.wf01002 + ' / ' + row.wf01001 + '】'
                this.globalFlowData = {
                    flowId: row.wf01001
                }
                this.globalTabCheck = this.globalSetOption.column[0]
                this.getWrokFlowGlobalByKey()
            },
            getWrokFlowGlobalByKey() {
                // console.log(this.globalTabCheck)
                let _this = this,
                    url = api.getWrokFlowGlobalByKey,
                    param = {}
                param['flowId'] = _this.globalFlowData.flowId
                param['key'] = _this.globalTabCheck.prop
                _this.axios.post(url, param).then((res) => {
                    if (res.data.code == 10000) {
                        if (JSON.stringify(res.data.data) != '{}') {
                            if (param['key'] === 'ordernumber') {
                                // console.log(res.data.data)
                                _this.ordernumberForm = res.data.data
                            } else if (param['key'] === 'systemname') {
                                _this.systemnameForm = res.data.data
                            } else if (param['key'] === 'systemworkflow') {
                                _this.systemworkflowForm = res.data.data
                            }
                        }
                    } else {
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                }).catch((err) => {
                    console.log('调用失败', err)
                })
            },
            handleCloseGlobal() {
                this.globalTitle = ''
                this.globalVisible = false
                this.globalFlowData = {}
            },
            globalSetHandleChange(column) {
                this.globalTabCheck = column
                this.getWrokFlowGlobalByKey()
            },
            globalTabSave() {
                let _this = this,
                    url = api.workFlowGlobalConfigSave,
                    param = {}
                param['flowId'] = _this.globalFlowData.flowId
                param['key'] = _this.globalTabCheck.prop
                param['keyTitle'] = _this.globalTabCheck.label
                if (param['key'] === 'ordernumber') {
                    param['config'] = _this.ordernumberForm
                } else if (param['key'] === 'systemname') {
                    param['config'] = _this.systemnameForm
                } else if (param['key'] === 'systemworkflow') {
                    param['config'] = _this.systemworkflowForm
                }

                _this.axios.post(url, param).then((res) => {
                    if (res.data.code == 10000) {
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'success'
                        });
                    } else {
                        _this.$message({
                            showClose: false,
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                }).catch((err) => {
                    console.log('调用失败', err)
                })
            },
            jobcolumnviewed(row) {
                let _this = this,
                    params = {
                        flowId: row.wf01001
                    }
                
                _this.axios.post(api.getJobsColumnByFlowId, params, {
                    responseType: 'blob'
                }).then(response => {
                    let data = response.data
                    let fileReader = new FileReader();
                    fileReader.onload = function() {
                        try {
                            let jsonData = JSON.parse(this.result);
                            _this.$message({
                                showClose: false,
                                message: jsonData.message,
                                type: 'info'
                            })
                        } catch (err) {
                            let blob = new Blob([response.data], {
                                type: 'application/vnd.ms-excel;charset=utf-8'
                            })
                            let filename = decodeURI(response.headers['content-disposition'].split('=')[1])
                                .replace(/^"*|"*$/g, '')
                            if ('download' in document.createElement('a')) { // 非IE下载
                                const elink = document.createElement('a')
                                elink.download = filename
                                elink.style.display = 'none'
                                elink.href = URL.createObjectURL(blob)
                                document.body.appendChild(elink)
                                elink.click()
                                document.body.removeChild(elink)
                                window.URL.revokeObjectURL(elink.href) //释放掉blob对象
                            } else { // IE10+下载
                                navigator.msSaveBlob(blob, filename)
                            }
                        }
                    };
                    fileReader.readAsText(data)
                }).catch((err) => {
                    console.log(err)
                    _this.$message({
                        showClose: false,
                        message: '导出失败',
                        type: 'error'
                    })
                })
            },
        }
    }
</script>

<style lang="scss">
    .custom-tree-node {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        font-size: 14px;
        padding-right: 8px;
    }

    .aside-tree {
        margin-right: 20px;
        height: 100%;
        overflow: auto;
    }
</style>
